home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Sound / Amster / Source / include / amster.h next >
Encoding:
C/C++ Source or Header  |  2001-03-11  |  20.8 KB  |  917 lines

  1. /*
  2. ** Amster
  3. **
  4. ** This program is free software; you can redistribute it and/or
  5. ** modify it under the terms of the GNU General Public License.
  6. **
  7. ** macros, structures, and prototypes
  8. */
  9.  
  10. #include <sys/types.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <stdarg.h>
  15. #include <sys/time.h>
  16. #include <time.h>
  17. #include <netinet/in.h>
  18.  
  19. #include "config.h"
  20. #include "compiler.h"
  21. #include "mui.h"
  22. #include "thread.h"
  23.  
  24. #ifndef INCLUDED_AMSTER_H
  25. #define INCLUDED_AMSTER_H
  26.  
  27. #ifndef __SASC
  28. /* replacement for sasc function */
  29. extern int stcd_i(const char *in, int *ivalue);
  30. #endif
  31.  
  32.  
  33. /*****  Napster Protocol  *****/
  34.  
  35. extern char nap_host[512];
  36. extern char nap_server[512+6];
  37. extern unsigned short nap_port;
  38.  
  39. extern u_long nap_sigmask;
  40. extern char *nap_buf;
  41. extern char *nap_linktype[];
  42.  
  43. extern struct Library *SocketBase;
  44. extern struct Locale *locale;
  45.  
  46.  
  47. typedef struct song_struct {
  48.     char *title;
  49.     char *md5;
  50.     u_long size;
  51.     int bit, freq, time;
  52.     char *user;
  53.     u_long ip;
  54.     int link;
  55. } *song, _song;
  56.  
  57. typedef struct listener_struct {
  58.     struct listener_struct *next;
  59.     thread t;
  60.     int ts;
  61.  
  62.     /* thread data */
  63.     struct Library *DOSBase;
  64.     struct Library *SocketBase;
  65.     long s;
  66.     u_long nsig, nsigm, msigm;
  67.     struct fd_set fds;
  68. } *listener, _listener;
  69.  
  70. #define NAPC_LOGINERROR        0
  71. #define NAPC_LOGIN_REQUEST     2    /* Jordan Ritter */
  72. #define NAPC_LOGINRESP         3
  73. #define NAPC_NEW_USER          6    /* Jordan Ritter */
  74. #define NAPC_CHECK_NAME        7    /* Jordan Ritter */
  75. #define NAPC_REGSUCCESS        8
  76. #define NAPC_REGUSED           9
  77. #define NAPC_NICKINVALID      10
  78. #define NAPC_NOTIFYSHARE     100
  79. #define NAPC_REMOVESHARE     102
  80. #define NAPC_SEARCH          200
  81. #define NAPC_SEARCHRESULT    201
  82. #define NAPC_SEARCHCOMPLETE  202
  83. #define NAPC_FILEINFOREQ     203
  84. #define NAPC_FILEINFO        204
  85. #define NAPC_PRIVATEMSG      205
  86. #define NAPC_GETERROR        206
  87. #define NAPC_HOTLIST_ADD     207
  88. #define NAPC_HOTLIST_INIT    208
  89. #define NAPC_USER_SIGNON     209
  90. #define NAPC_USER_SIGNOFF    210
  91. #define NAPC_BROWSEUSER      211
  92. #define NAPC_BROWSERESULT    212
  93. #define NAPC_BROWSECOMPLETE  213
  94. #define NAPC_FILECOUNT       214
  95. #define NAPC_DLINC           218
  96. #define NAPC_DLCOMPLETE      219
  97. #define NAPC_ULINC           220
  98. #define NAPC_ULCOMPLETE      221
  99. #define NAPC_HOTLIST_ACK     301
  100. #define NAPC_HOTLIST_ERROR   302
  101. #define NAPC_HOTLIST_REMOVE  303
  102. #define NAPC_CHANNELJOIN     400
  103. #define NAPC_CHANNELPART     401
  104. #define NAPC_PUBLICMSGSEND   402
  105. #define NAPC_PUBLICMSGRECV   403
  106. #define NAPC_GENERALERROR    404
  107. #define NAPC_JOINACK         405
  108. #define NAPC_JOINMSG         406
  109. #define NAPC_USERPART        407
  110. #define NAPC_USERLIST        408
  111. #define NAPC_USERLISTEND     409
  112. #define NAPC_CHANNELTOPIC    410
  113. #define NAPC_ALTDLREQ        500
  114. #define NAPC_ALTDLACK        501
  115. #define NAPC_WHOIS           603
  116. #define NAPC_WHOISRESP       604
  117. #define NAPC_WHOWASRESP      605
  118. #define NAPC_UPLOADREQ       607
  119. #define NAPC_UPLOADACCEPT    608
  120. #define NAPC_GETERROR2       609
  121. #define NAPC_LIST_CHANNELS   617
  122. #define NAPC_CHANNEL_ENTRY   618
  123. #define NAPC_LOCALQUEUEFULL  619
  124. #define NAPC_REMOTEQUEUEFULL 620
  125. #define NAPC_SYSMSG          621
  126. #define NAPC_GLOBALMSG       628
  127. #define NAPC_EMAILCHANGE     702
  128.  
  129. extern void nap_login_fromlist(char *server, unsigned short port);
  130. extern void nap_login(void);
  131. extern void nap_logout(void);
  132. extern void nap_listen(void);
  133. extern void nap_send(u_int com);
  134. extern int nap_sendbuf(u_int com, char *buf);
  135. extern void nap_songfree(song s);
  136. extern song nap_songdup(song s);
  137.  
  138. extern char *nap_strippath(char *name);
  139. extern char *nap_token(char **str);
  140. extern int nap_itoken(char **str);
  141. extern u_long nap_ltoken(char **str);
  142. extern void ListenerMsgHandler(thread t, int com, APTR data);
  143. THREAD_DECL(createlistener);
  144.  
  145.  
  146.  
  147. /*****  GUI Stuff  *****/
  148.  
  149. extern struct guidata *gui;
  150. extern enum OnlineState gui_onlinestate;
  151. extern int UseLamps;    /* search.c needs this */
  152. extern int UseTWF;        /* search.c needs this */
  153. extern listener l;        /* Information for listener thread */
  154.  
  155. enum OnlineState {
  156.     DISCONNECTED,
  157.     OFFLINE,
  158.     CONNECTING,
  159.     LOGGING_IN,
  160.     ONLINE
  161. };
  162.  
  163. struct guidata {
  164.     struct MUI_CustomClass *url_mcc;
  165.     struct MUI_CustomClass *panel_mcc;
  166.     struct MUI_CustomClass *search_mcc;
  167.     struct MUI_CustomClass *resultview_mcc;
  168.     struct MUI_CustomClass *dl_mcc;
  169.     struct MUI_CustomClass *ul_mcc;
  170.     struct MUI_CustomClass *share_mcc;
  171.     struct MUI_CustomClass *prf_mcc;
  172.     struct MUI_CustomClass *about_mcc;
  173.     struct MUI_CustomClass *info_mcc;
  174.     struct MUI_CustomClass *msg_mcc;
  175.     struct MUI_CustomClass *chat_mcc;
  176.     struct MUI_CustomClass *chatline_mcc;
  177.     struct MUI_CustomClass *navi_mcc;
  178.     struct MUI_CustomClass *hotlist_mcc;
  179.     struct MUI_CustomClass *channellist_mcc;
  180.     u_long *app;
  181.     u_long *iconpanelmenu;
  182.     u_long *win;
  183.     u_long *maingrp, *searchpanel, *statgrp, *stat, *lamp, *inbut, *outbut, *rebut, *rect, *iconpanel;
  184.     u_long *swin;
  185.     u_long *shwin;
  186.     u_long *iwin;
  187.     u_long *mwin;
  188.     u_long *dwin;
  189.     u_long *uwin;
  190.     u_long *awin;
  191.     u_long *WI_Navigator, *WI_ConnectTo;
  192.     u_long *WI_Hotlist;
  193.     u_long *WI_ChannelList;
  194.  
  195.     /* Connect to... */
  196.     u_long *ST_ConnectServer, *ST_ConnectPort, *ST_ConnectUser, *ST_ConnectPw, *TG_ConnectReg;
  197.     u_long *BT_ConnectServer;
  198.  
  199.     /* Stat variables */
  200.     int Songs, Libraries, Gigabytes;
  201.     u_long OnlineSince;
  202.  
  203.     /* For now, let these variables live among the GUI instance data */
  204.     char *ConnectUser, *ConnectPw;
  205. };
  206.  
  207. enum {
  208.     CONNECT,
  209.     DISCONNECT,
  210.     RECONNECT,
  211.     CONNECTSERVER,
  212.     EXECUTEAREXX,
  213.     UPDATEPANEL,
  214.     DEICONIFIED
  215. };
  216.  
  217.  
  218.  
  219. /*****  Custom Class Dispatchers  *****/
  220.  
  221. MUI_DISPATCH_DECL(about_dispatch);
  222. MUI_DISPATCH_DECL(ChannelListDispatch);
  223. MUI_DISPATCH_DECL(chat_dispatch);
  224. MUI_DISPATCH_DECL(UserlistContextDispatcher);
  225. MUI_DISPATCH_DECL(resultview_dispatch);
  226. MUI_DISPATCH_DECL(ResultviewContextDispatcher);
  227. MUI_DISPATCH_DECL(info_dispatch);
  228. MUI_DISPATCH_DECL(ul_dispatch);
  229. MUI_DISPATCH_DECL(dl_dispatch);
  230. MUI_DISPATCH_DECL(msg_dispatch);
  231. MUI_DISPATCH_DECL(HotlistDispatch);
  232. MUI_DISPATCH_DECL(NavigatorDispatch);
  233. MUI_DISPATCH_DECL(prf_dispatch);
  234. MUI_DISPATCH_DECL(search_dispatch);
  235. MUI_DISPATCH_DECL(share_dispatch);
  236. MUI_DISPATCH_DECL(panel_dispatch);
  237.  
  238.  
  239.  
  240. /*****  Custom Class Methods & Attributes  *****/
  241.  
  242. #define DL_ADD            0x1003
  243. #define DL_START          0x1004
  244. #define DL_STARTINCOMING  0x1005
  245. #define DL_UPDATE         0x1010
  246. #define DL_CPS            0x1011
  247. #define DL_PLAY           0x1020
  248. #define DL_ABORT          0x1021
  249. #define DL_RESUME         0x1022
  250. #define DL_CLEANUP        0x1023
  251. #define DL_CLEANUP_SINGLE 0x1024
  252. #define DL_COUNTDECREMENT 0x1040
  253. #define DL_COUNTINCREMENT 0x1041
  254. #define DL_CHECKQUEUE     0x1042
  255. #define DL_RESUME_UPDATE  0x1049
  256. #define DL_INFO           0x1050
  257. #define DL_SETERROR       0x1051
  258. #define DL_RETRY          0x1052
  259. #define DL_POLLWAIT       0x1053
  260. #define DL_SETDELAY       0x1054
  261. #define DL_REMWAITING     0x1055
  262. #define DL_WATCHER        0x1056
  263.  
  264. #define UPLOAD_OPEN           0x1301
  265. #define UPLOAD_CLOSE          0x1302
  266. #define UPLOAD_UPDATE         0x1303
  267. #define UPLOAD_CPS            0x1304
  268. #define UPLOAD_ADD            0x1305
  269. #define UPLOAD_START          0x1306
  270. #define UPLOAD_ABORT          0x1308
  271. #define UPLOAD_INFO           0x1309
  272. #define UPLOAD_CLEANUP        0x1310
  273. #define UPLOAD_CLEANUP_SINGLE 0x1311
  274. #define UPLOAD_WATCHER        0x1312
  275. #define UPLOAD_COUNTINCREMENT 0x1313
  276. #define UPLOAD_COUNTDECREMENT 0x1314
  277.  
  278. #define NAVI_CONNECT      0x1501
  279. #define NAVI_GETSERVER    0x1502
  280. #define NAVI_ADDSERVER    0x1503
  281. #define NAVI_REMOVESERVER 0x1504
  282. #define NAVI_SAVE         0x1505
  283. #define NAVI_MARKSERVER   0x1506
  284. #define NAVI_REDRAWSERVER 0x1507
  285. #define NAVI_LOAD         0x1508
  286. #define NAVI_GETNAPIGATOR 0x1509
  287.  
  288. #define CHANLIST_ENTRY   0x1801
  289. #define CHANLIST_UPDATE  0x1802
  290. #define CHANLIST_JOIN    0x1803
  291.  
  292. #define HOTLIST_LOAD           0x2001
  293. #define HOTLIST_SAVE           0x2002
  294. #define HOTLIST_UPLOAD         0x2003
  295. #define HOTLIST_SIGNON         0x2004
  296. #define HOTLIST_SIGNOFF        0x2005
  297. #define HOTLIST_REMOVE         0x2006
  298. #define HOTLIST_BROWSE         0x2007
  299. #define HOTLIST_FOUND          0x2008
  300. #define HOTLIST_NICK           0x2009
  301. #define HOTLIST_CLEAR          0x2010
  302. #define HOTLIST_TOGGLE         0x2011
  303. #define HOTLIST_TOGGLE_RESULTS 0x2012
  304. #define HOTLIST_SIGNOFF_ALL    0x2013
  305. #define HOTLIST_ADD            0x2014
  306.  
  307. #define PRF_OPEN       0x2001
  308. #define PRF_CANCEL     0x2002
  309. #define PRF_USE        0x2003
  310. #define PRF_SAVE       0x2004
  311. #define PRF_UPDATE     0x2005
  312. #define PRF_SAVEALL    0x2006
  313. #define PRF_TESTSND    0x2007
  314. #define PRF_ENTRY      0x2009
  315. #define PRF_LASTSAVED  0x2010
  316. #define PRF_VALIDDELAY 0x2011
  317.  
  318. #define INFO_MSG 0x3001
  319.  
  320. #define MSG_OPEN   0x4001
  321. #define MSG_GOT    0x4002
  322. #define MSG_SAY    0x4003
  323. #define MSG_WHOIS  0x4004
  324. #define MSG_WHOWAS 0x4005
  325.  
  326. #define SEARCH_GO       0x5001
  327. #define SEARCH_CLEAR    0x5002
  328. #define SEARCH_NICK     0x5004
  329. #define SEARCH_FOUND    0x5005
  330. #define SEARCH_RESET    0x5006
  331. #define SEARCH_TOGGLE   0x5007
  332. #define SEARCH_SET      0x5009
  333. #define SEARCH_GET      0x5010
  334. #define SEARCH_USE      0x5011
  335. #define SEARCH_GETSTATE 0x5012
  336. #define SEARCH_FILLSTEM 0x5013
  337. #define SEARCH_DOWNLOAD 0x5014
  338. #define SEARCH_ADDTOHOTLIST 0x5015
  339. #define SEARCH_NICKFROMLIST 0x5016
  340.  
  341. #define RESULTVIEW_CLEAR    0x5002
  342. #define RESULTVIEW_DOWNLOAD 0x5003
  343. #define RESULTVIEW_NICK     0x5004
  344. #define RESULTVIEW_FOUND    0x5005
  345. #define RESULTVIEW_TOGGLE_ONE  0x5008
  346. #define RESULTVIEW_TOGGLE_BOTH 0x5009
  347. #define RESULTVIEW_STAT     0x5012
  348. #define RESULTVIEW_INSERT   0x5013
  349. #define RESULTVIEW_RESETCOUNT 0x5014
  350. #define RESULTVIEW_STAT2    0x5015
  351. #define RESULTVIEW_GETSTATE 0x5016
  352. #define RESULTVIEW_FILLSTEM 0x5017
  353. #define RESULTVIEW_ADDTOHOTLIST 0x5018
  354. #define RESULTVIEW_NICKFROMLIST 0x5019
  355.  
  356. #define PANEL_OPENDEBUG 0x6001
  357. #define PANEL_CLOSEDEBUG 0x6002
  358. #define PANEL_OPENDL 0x6003
  359. #define PANEL_CLOSEDL 0x6004
  360. #define PANEL_OPENSHARE 0x6005
  361. #define PANEL_CLOSESHARE 0x6006
  362. #define PANEL_OPENPRF 0x6007
  363. #define PANEL_CLOSEPRF 0x6008
  364. #define PANEL_OPENABOUT 0x6009
  365. #define PANEL_OPENMSG 0x6010
  366. #define PANEL_NEWCHAT 0x6012
  367. #define PANEL_DISPOSECHAT 0x6013
  368.  
  369. #define SHARE_OPEN      0x7001
  370. #define SHARE_CLOSE     0x7002
  371. #define SHARE_ADD       0x7003
  372. #define SHARE_ADDDIR    0x7004
  373. #define SHARE_REMOVE    0x7005
  374. #define SHARE_LOAD      0x7006
  375. #define SHARE_LOADAS    0x7007
  376. #define SHARE_SAVE      0x7008
  377. #define SHARE_SAVEAS    0x7009
  378. #define SHARE_UPLOAD    0x7010
  379. #define SHARE_NOTIFYALL 0x7011
  380. #define SHARE_PLAY      0x7012
  381. #define SHARE_ADDFILE   0x7013
  382. #define SHARE_ADDFILEN  0x7014
  383. #define SHARE_SETDIR    0x7015
  384. #define SHARE_UPDCOUNT  0x7016
  385.  
  386. #define CHAT_COMMAND       0x9001
  387. #define CHAT_JOINCHANNEL   0x9005
  388. #define CHAT_JOINACK       0x9010
  389. #define CHAT_PUBLICMSGRECV 0x9011
  390. #define CHAT_JOINMSG       0x9012
  391. #define CHAT_CHANNELTOPIC  0x9013
  392. #define CHAT_USERPART      0x9014
  393. #define CHAT_CHANNELPART   0x9015
  394. #define CHAT_USERLIST      0x9016
  395.  
  396.  
  397.  
  398. /*****  Navigator  *****/
  399.  
  400. struct NavigatorData {
  401.     u_long *LV_Server, *ST_Server, *ST_Port, *ST_Comment;
  402. };
  403.  
  404. struct ServerEntry {
  405.     char *Name;
  406.     unsigned short Port;
  407.     char *Comment;
  408.     u_long LastOnline;
  409.     int Ping;
  410.     u_long Giga;
  411.     u_long Users;
  412.     u_long Songs;
  413. };
  414.  
  415. extern ULONG NavigatorNew(struct IClass *cl, Object *obj, struct opSet *msg);
  416.  
  417. extern BOOL ServerListChanged;
  418.  
  419.  
  420.  
  421. /*****  Icon Panel  *****/
  422.  
  423. struct paneldata {
  424.     u_long *logo,*infoicon,*dlicon,*shareicon,*prficon;
  425. };
  426.  
  427.  
  428.  
  429. /*****  Hotlist  *****/
  430.  
  431. struct HotlistData {
  432.     u_long *LV_Hotlist, *LV_Search, *TG_Results, *ST_Nick;
  433. };
  434.  
  435. struct HotlistEntry {
  436.     char *Nick;
  437.     int Speed;
  438.     int Online;
  439. };
  440.  
  441. extern ULONG HotlistNew(struct IClass *cl, Object *obj, struct opSet *msg);
  442. extern void HotlistInterpret(u_int com, char *data);
  443.  
  444. extern BOOL HotlistChanged;
  445.  
  446.  
  447.  
  448. /*****  Channel List  *****/
  449.  
  450. struct ChannelListData {
  451.     u_long *LV_Channel;
  452. };
  453.  
  454. struct ChannelEntry {
  455.     char *Name;
  456.     int NumUsers;
  457.     char *Topic;
  458. };
  459.  
  460. extern ULONG ChannelListNew(struct IClass *cl, Object *obj, struct opSet *msg);
  461.  
  462.  
  463.  
  464. /*****  Chat Window Class  *****/
  465.  
  466. extern struct MUI_CustomClass *UserlistContext;
  467.  
  468. typedef struct channel_struct {
  469.     struct channel_struct *next;
  470.     int joinflag;
  471.     char *name;
  472.     u_long *win;
  473. } *channel, _channel;
  474.  
  475. struct chatdata {
  476.     _channel chn;
  477.     u_long *rect,*chantxt,*topicstr;
  478.     u_long *msglist,*userlist;
  479.     u_long *msgstr;
  480. };
  481.  
  482. struct UserlistContextData
  483. {
  484.     u_long *MI_AddToHotlist;
  485.     u_long *MI_BrowseUser;
  486. };
  487.  
  488. struct ChannelUserData {
  489.     char *Name;
  490.     int Shares;
  491.     int Link;
  492.     char *Display; /* storage for the display hook */
  493. };
  494.  
  495. /* Global variables */
  496. extern channel chat_chans;
  497.  
  498. /* Global prototypes */
  499. extern channel chat_findchan(char *name);
  500.  
  501.  
  502.  
  503. /*****  Resultview Class  ******/
  504.  
  505. extern struct MUI_CustomClass *ResultviewContext;
  506.  
  507. #define MUIA_Amster_ContextMenu 0x50000001
  508.  
  509. extern char *gColFormat;
  510. extern int gContextChoice;
  511.  
  512. struct resultdata {
  513.     u_long *result, *list;
  514.     u_long *BT_Clear, *BT_ClearAll, *BT_Resume, *BT_Download, *fptog;
  515.     int resultview_count;
  516.     int resultview_state;
  517. };
  518.  
  519. struct ResultviewContextData
  520. {
  521.     u_long *MI_AddToHotlist;
  522.     u_long *MI_BrowseUser;
  523. };
  524.  
  525. enum {
  526.     CLEAR_MARKED,
  527.     CLEAR_ALL
  528. };
  529.  
  530.  
  531.  
  532. /*****  Debug Window *****/
  533.  
  534. struct infodata {
  535.     u_long *msglist;
  536. };
  537.  
  538.  
  539.  
  540. /*****  Msg  *****/
  541.  
  542. struct msgdata {
  543.     u_long *msglist;
  544.     u_long *msgstr;
  545. };
  546.  
  547. struct ChatMessage {
  548.     char TStamp[11];
  549.     char *Nick;
  550.     char *Msg;
  551. };
  552.  
  553. extern void msg_got(struct msgdata *data, char *nick, char *msg);
  554. extern void msg_gotwhois(char *buf);
  555.  
  556.  
  557.  
  558. /*****  Share  *****/
  559.  
  560. #define ARG_PATH     0
  561. #define ARG_MD5      1
  562. #define ARG_SIZE     2
  563. #define ARG_BITRATE  3
  564. #define ARG_FREQ     4
  565. #define ARG_TIME     5
  566. #define ARG_REQCOUNT 6
  567.  
  568. extern BOOL sharechanged;
  569.  
  570. typedef struct sharedata_struct {
  571.     char title[256];
  572.     char md5[33];
  573.     unsigned long size;
  574.     int bitrate, freq, time;
  575.     int reqcount;
  576. } *sharedata, _sharedata;
  577.  
  578. struct shdata {
  579.     u_long *list, *stat;
  580. };
  581.  
  582. /* Prototypes */
  583. ULONG share_new(struct IClass *cl, Object *obj, struct opSet *msg);
  584. MUI_LIST_DEST_DECL(sharelistdest, sharedata sd);
  585. MUI_LIST_DEST_DECL(sharelistdisp, sharedata sd);
  586. MUI_NLIST_COMP_DECL(sharelistcomp);
  587. MUI_APPMSG_DECL(ShareListAppMsgFunc);
  588.  
  589. /* Private */
  590. void add_filename(struct shdata *data, char *fname);
  591. void add_file(struct shdata *data, song sdl, char *fname);
  592. void add_shares(struct shdata *data);
  593. void add_directory(struct shdata *data);
  594. void add_recursive(struct shdata *data, sharedata sd, BPTR dirlock, const char *dirname);
  595. void add_shareinfo(struct shdata *data, sharedata sd, BPTR lock);
  596. void notify_shares(struct shdata *data);
  597. void remove_shares(struct shdata *data, long t);
  598. void save_shares(struct shdata *data);
  599. void save_shares_as(struct shdata *data);
  600. void load_shares(struct shdata *data, int merge);
  601. void load_shares_as(struct shdata *data, int merge);
  602. void update_stat(struct shdata *data);
  603. void play_share(struct shdata *data);
  604. void upload_file_confirm(struct shdata *data, char *user, char *fname);
  605. void update_count(struct shdata *data, char *fname);
  606. void nap_notifyshare(sharedata sd);
  607. BOOL IsIn(char *string, char c);
  608.  
  609. /* Public prototypes */
  610. extern char *strrep(char *str1, char *old_str, char *new_str);
  611. extern char *MakeWinPath(char *AmigaPath);
  612.  
  613.  
  614.  
  615. /*****  Common Transfer Stuff  *****/
  616.  
  617. struct TransferData {
  618.     struct MUI_InputHandlerNode ihnode;
  619.     struct MUI_InputHandlerNode waitnode;
  620.     struct MUI_InputHandlerNode watchnode;
  621.     u_long *list;
  622.     u_long *info;
  623.     u_long *BT_Resume;
  624. };
  625.  
  626. /* Download states
  627.    - IMPORTANT: These states MUST be in the same order as the
  628.      catalog string array in transfer.c
  629. */
  630. enum TransferState {
  631.     DLS_PREP,
  632.     DLS_QUEUE,
  633.     DLS_WAIT,
  634.     DLS_CON,
  635.     DLS_REQ,
  636.     DLS_INIT,
  637.     DLS_DOWN,
  638.     DLS_UP,
  639.     DLS_FIN,
  640.     DLS_ABORT,
  641.     DLS_ERROR
  642. };
  643.  
  644. /* Transfer errors
  645.    - IMPORTANT: These errors MUST be in the same order as the
  646.      catalog string array in transfer.c
  647. */
  648. enum TransferError {
  649.     ERROR_UNKNOWN,
  650.     ERROR_FILEOPEN,
  651.     ERROR_FILEREAD,
  652.     ERROR_FILEWRITE,
  653.     ERROR_NET,
  654.     ERROR_LOGGEDOUT,
  655.     ERROR_NOTFOUND,
  656.     ERROR_INVALIDREQUEST,
  657.     ERROR_TEASER,
  658.     ERROR_BUSY,
  659.     ERROR_NOTREQUESTED,
  660.     ERROR_TIMEOUT,
  661.     ERROR_OUTOFBOUND
  662. };
  663.  
  664. enum NetError {
  665.     ERROR_NET_TIMEOUT,
  666.     ERROR_NET_REFUSED,
  667.     ERROR_NET_RESET,
  668.     ERROR_NET_PIPE
  669. };
  670.  
  671. enum TransferType {
  672.     TYPE_DOWNLOAD_IN,
  673.     TYPE_DOWNLOAD_OUT,
  674.     TYPE_UPLOAD_IN,
  675.     TYPE_UPLOAD_OUT
  676. };
  677.  
  678. typedef struct songtrans_struct {
  679.     struct songtrans_struct *next;
  680.     song song;
  681.     char *mynick;
  682.     u_long ip;
  683.     char host[512];
  684.     int port;
  685.     char *fname;
  686.     u_long size, cur, resumestart;
  687.     enum TransferType type;
  688.     enum TransferState state;
  689.     enum TransferError error;
  690.     int ErrorCode;
  691.     int RetryCount;
  692.     thread t;
  693.     int ts;
  694.     int cps, stalltick;
  695.     u_long oldsize;
  696.     time_t reqtime;    /* Time when the request is made */
  697.     time_t starttime, transtime, timeleft;
  698.  
  699.     /* thread data */
  700.     struct Library *DOSBase;
  701.     struct Library *SocketBase;
  702.     long s;
  703.     char *buffer;
  704.     BPTR f;
  705.     u_long nsig, nsigm, msigm;
  706.     struct sockaddr_in sin;
  707.     struct fd_set fds;
  708.     struct timeval tv;
  709. } *songtrans, _songtrans;
  710.  
  711. extern ULONG dl_setup(struct IClass *cl, Object *obj, Msg msg);
  712. extern ULONG dl_muicleanup(struct IClass *cl, Object *obj, Msg msg);
  713. extern MUI_LIST_DISP_DECL(translistdisp, songtrans sd);
  714. extern MUI_LIST_DEST_DECL(translistdest, songtrans sd);
  715. extern void CalculateCps(songtrans sd);
  716. extern void TransferSetError(struct TransferData *data, char *title, char *user, int error);
  717. extern void TransferInfo(struct TransferData *data);
  718. extern void TransferAbort(struct TransferData *data);
  719. extern void TransferCleanup(struct TransferData *data);
  720. extern void TransferCleanupSingle(struct TransferData *data, songtrans sd);
  721. extern void TransferWatcher(struct TransferData *data);
  722. extern void TransferHandleError(songtrans sd);
  723. extern BOOL InitTransferThread(thread t, songtrans sd);
  724. extern void ExitTransferThread(songtrans sd, int ret);
  725.  
  726.  
  727.  
  728. /*****  Upload  *****/
  729.  
  730. extern int ul_count;
  731.  
  732. extern void ul_addq(song s);
  733. extern void ul_startq(char *title, char *user, u_long ip, int port, int link);
  734.  
  735. /* Private */
  736. void ul_startq2(struct TransferData *data, char *title, char *user, u_long ip, int port);
  737. void ul_abort(struct TransferData *data);
  738. void ul_handlemsg(thread t, int com, APTR data);
  739. THREAD_DECL(UploadThread);
  740.  
  741.  
  742.  
  743. /*****  Download  *****/
  744.  
  745. extern int dl_count;
  746. extern int QueueCount;
  747.  
  748. enum HandlerFunc {
  749.     DLC_STATE,
  750.     DLC_SIZE,
  751.     DLC_ADDSHARE,
  752.     DLC_UPDATE
  753. };
  754.  
  755.  
  756.  
  757. /*****  Search Area  *****/
  758.  
  759. extern int search_state;
  760.  
  761. struct SearchArgs {
  762.     char *String;
  763.     int MaxResults;
  764. };
  765.  
  766. struct searchdata {
  767.     u_long *str, *maxstr;
  768.     u_long *pop;
  769.     u_long *popspeed, *popspeedval, *popbit, *popbitval, *popfreq, *popfreqval;
  770.     u_long *LV_Search;
  771. };
  772.  
  773.  
  774.  
  775. /*****  Preferences  *****/
  776.  
  777. extern struct prefsdata *prf;
  778. extern struct MUI_CustomClass *QueueClass;
  779.  
  780. enum Event {
  781.     PRFE_STARTUP,
  782.     PRFE_EXIT,
  783.     PRFE_CONNECT,
  784.     PRFE_DISCONNECT,
  785.     PRFE_DLSTART,
  786.     PRFE_DLFINISH,
  787.     PRFE_DLERROR,
  788.     PRFE_DLABORT,
  789.     PRFE_ULSTART,
  790.     PRFE_ULFINISH,
  791.     PRFE_ULERROR,
  792.     PRFE_ULABORT,
  793.     PRFE_INMSG,
  794.     PRFE_LIB_DCLICK,
  795.     PRFE_DL_DCLICK,
  796.     PRFE_PLAYMP3,
  797.     PRFE_END
  798. };
  799.  
  800. struct prefsdata {
  801.     /* User */
  802.     char *user;
  803.     char *pass;
  804.     char *dlpath;
  805.     char *email;
  806.     int link;
  807.     int BypassRegistration;
  808.     int regflag;
  809.     /* Options */
  810.     int clrlist;
  811.     int fullpath;
  812.     int autocon;
  813.     int askfile;
  814.     int autoadd;
  815.     int autosave;
  816.     int AutoCleanup;
  817.     int NameLength;
  818.     /* Events */
  819.     char *scripts[PRFE_END];
  820.     char *sounds[PRFE_END];
  821.     /* Advanced */
  822.     char *napvers;
  823.     char *MetaServer, *LeafServer;
  824.     unsigned short MetaPort, LeafPort;
  825.     unsigned short port;
  826.     int DownloadQueueLimit;
  827.     int DownloadTaskPri;
  828.     int UploadQueueLimit;
  829.     int UploadTaskPri;
  830.     int QueueRetries;
  831.     int QueueDelay;
  832.     /* Startup */
  833.     int noiconpanel;
  834.     int lamps;
  835.     int ServerList;
  836.     /* Search */
  837.     int speedqual, speedval;
  838.     int bitratequal, bitrateval;
  839.     int freqqual, freqval;
  840.     int max;
  841.     char ColumnOrder[9];
  842. };
  843.  
  844.  
  845. struct prfdata {
  846.     u_long *ST_User, *ST_Password, *ST_EMail, *TG_BypassReg, *ST_DLPath, *CY_LinkSpeed;
  847.     u_long *TG_ClearList, *TG_AutoConnect, *TG_AskFile, *TG_AutoAdd, *TG_AutoSave, *CM_ServerList;
  848.     u_long *CY_ServerList, *CY_AutoCleanup, *CY_Lamp, *ST_NameLength;
  849.     u_long *LI_Event, *ST_EventScript, *ST_EventSound;
  850.     u_long *ST_MetaServer, *ST_MetaPort, *ST_Server, *ST_LeafPort, *ST_Port, *TG_Firewall;
  851.     u_long *SL_DownloadQueue, *SL_UploadQueue;
  852.     u_long *SL_DownloadPri, *SL_UploadPri;
  853.     u_long *ST_QueueRetries, *ST_QueueDelay;
  854. /*    u_long *VersionString;*/
  855.     int lastitem;
  856. };
  857.  
  858. struct QueueData
  859. {
  860.     char buf[21];
  861. };
  862.  
  863. extern BOOL prf_load(char *fname);
  864. extern void prf_save(char *fname);
  865. extern void prf_setup(int argc, char *argv[]);
  866. extern void prf_event(enum Event no, ...);
  867.  
  868. #define PRF_DEFAULT_PORT 6699
  869.  
  870.  
  871.  
  872. /*****  ARexx  *****/
  873.  
  874. enum RexxCommand {
  875.     NONE,
  876.     WHOIS,
  877.     SEARCH
  878. };
  879.  
  880. extern ULONG gRC;
  881. extern enum RexxCommand gRexxCommand;
  882. extern char *gSTEM;
  883.  
  884. extern struct MUI_Command rexx_cmds[];
  885.  
  886. extern u_long rexx_sendcommand(char *port, char *com);
  887. extern void rexx_execute(char *com, char *argfmt, ...);
  888.  
  889.  
  890.  
  891. /*****  Prototypes  *****/
  892.  
  893. extern int lamp_create(void);
  894. extern void lamp_dispose(void);
  895. extern void lamp_useinlist(u_long *list);
  896. extern char *lamp_getforlist(int i);
  897.  
  898. extern void gui_run(u_long tcpsig);
  899. extern void gui_state(enum OnlineState s);
  900. extern void gui_stat(char *msg, ...);
  901. extern void gui_srvstat(int Libraries, int Songs, int Gigabytes);
  902. extern void localize_array(char *array[]);
  903. extern void gui_found(struct song_struct *s, int type);
  904.  
  905. extern void gui_debug(char *msg);
  906. extern void gui_debugf(char *msg, ...);
  907.  
  908. extern void chat_interpret(u_int com, char *data);
  909.  
  910. extern void dl_addq(struct song_struct *s);
  911.  
  912. extern time_t GetDateStamp(void);
  913.  
  914.  
  915.  
  916. #endif    /* INCLUDED_AMSTER_H */
  917.